﻿using Common;
using Microsoft.Practices.CompositeWeb;
using Microsoft.Practices.ObjectBuilder;

namespace CSC440TeamOne.MyNutrition.Views
{
    /// <summary>
    /// Name - PrintRecipePresenter.cs
    /// Description - Encapsulates all client requests from the PrintRecipeViewModel
    /// Programmer - Nivasan Pillay
    /// Date coded - 11/13/2011
    /// Arguments - IPrintRecipeView
    /// Variables - None
    /// Files accessed by this code artifact - None
    /// Files changed by this code artifact - None
    /// I/O - None
    /// Error Handling - None
    /// Modifications -
    ///     1.0 - Initial coding
    /// Known Faults -
    ///     1.0 None Known
    /// </summary>
    public class PrintRecipePresenter : Presenter<IPrintRecipeView>
    {

        // NOTE: Uncomment the following code if you want ObjectBuilder to inject the module controller
        //       The code will not work in the Shell module, as a module controller is not created by default
        //
         private IMyNutritionController _controller;

         /// <summary>
         /// Initializes a new instance of <see cref="PrintRecipePresenter"/> class.
         /// </summary>
         /// <param name="controller">The controller.</param>
         public PrintRecipePresenter([CreateNew] IMyNutritionController controller)
         {
         		_controller = controller;
         }

        public override void OnViewLoaded()
        {
            // TODO: Implement code that will be executed every time the view loads


        }

        public override void OnViewInitialized()
        {
            // TODO: Implement code that will be executed the first time the view loads

            /*MyRecipeViewModel model = _controller.LoadMyRecipeViewModelForCurrentUser();
            _controller.loadRecipe(model);
            model.selectedRecipeID = id;*/

            //var model2 = _controller.LoadMyRecipeViewModelForCurrentUser(View.RecipID);
            //View.Show(model2);

            //This call is supposed to be the correct one, but it does not display any recipe.
            //View.Show(_controller.LoadPrintableRecipe(View.RecipID));

            //This call only displays the recipe for Taco Salad.
            View.Show(_controller.LoadPrintableRecipe2(View.RecipID));
        }

        // TODO: Handle other view events and set state in the view

        /// <summary>
        /// Retrieves a selected recipe by ID
        /// </summary>
        /// <param name="p">A selected recipe p that correlates to a specific ID.</param>
        /*public MyRecipeViewModel recipeSelected(int p)
        {
            var model = _controller.LoadMyRecipeViewModelForCurrentUser();
            model.selectedRecipeID = p;
            _controller.loadRecipe(model);
            return model;
        }*/

        /// <summary>
        /// Retrieves a selected recipe by "term" (keyword/search)
        /// </summary>
        /// <param name="p">A selected recipe p that correlates to certain keywords.</param>
        /*public MyRecipeViewModel getRecipesByValue(string p)
        {
            var model = _controller.LoadMyRecipeViewModelForCurrentUser();
            model.recipeTerm = p;
            return _controller.loadRecipesByValue(model);
        }*/
    }
}




